import request from './request'
import store from "../store/index"



//登录
export function login(data){
  return request({
    url:'/admin/login',
    method:'post',
    params:{
        name:data.name,
        password:data.password,
        ip:data.ip,
        captcha:data.captcha,
    }
  })
}

//注销登录
export function logout(){
  return request({
    url:'/admin/logout',
  })
}

//获取学校企业申请列表
export function getAppList(type){
  return request({
    url:'/admin/auditUnit',
    params:{
      type,
      index:1
    },
  })
}

//分页请求 审核列表
export function getAuditPageList(type,index){
  return request({
    url:'/admin/auditUnit',
    params:{
      type,
      index
    }
  })
}
//获取入驻机构列表
export function getUnitList(type){
  return request({
    url:'/admin/unitList',
    params:{
      type,
      index:1
    },

  })
}

//学校信息更新
export function upUniversity(university){
  return request({
    url:'/admin/university',
    method:'put',
    data:university
  })
}

//企业信息更新
export function upCompany(company){
  return request({
    url:'/admin/company',
    method:'put',
    data:company
  })
}
//学生信息更新
export function upStudent(student){
  return request({
    url:'/admin/student',
    method:'put',
    data:student
  })
}

//分页请求 列表
export function getPageList(type,index){
  return request({
    url:'/admin/unitList',
    params:{
      type,
      index
    }
  })
}


//机构列表搜索
export function searchUnit(type,name){
  return request({
    url:'/admin/searchUnit',
    params:{
      type,name,index:1
    }
  })
}

//机构删除
export function delUnit(type,id){
  return request({
    url:'/admin/delUnit/'+id,
    method:"delete",
    params:{
      type
    }
  })
}

//获取审核详情
export function getAppDetails(type,id){
  return request({
    url:'/admin/details/'+id,
    method:'get',
    params:{
      type
    }
  })
}

//审核未通过
export function appFail(id,type){
  return request({
    url:'/admin/auditUnitFail/'+id,
    method:'put',
    params:{
      type
    }
  })
}

//审核通过
export function appSuccess(id,type){
  return request({
    url:'/admin/auditUnitSuccess/'+id,
    method:'put',
    params:{
      type
    }
  })
}

//密码修改
export function pwdChange(data){
  return request({
    url:'/admin/upPwd',
    method:'put',
    params:{
      id:localStorage.getItem("id"),
      password:data.passWord,
      newPassword:data.newPassword,
      rePassword:data.rePassword
    }
  })
}

//获取视频
export function getVideo() {
  return request({
    url:'/admin/data',
  })
}

//更新视频标题
export function upTitle(id,title) {
  return request({
    url:'/admin/upTitle/'+id,
    method:'put',
    params:{
      title
    }
  })
}

//删除视频
export function delVideo(id) {
  return request({
    url:'/admin/data/'+id,
    method:'delete'
  })
}

//获取举报类型
export function getReportTypes() {
  return request({
    url:'/admin/reportKind'
  })
}

//添加举报类型
export function addReportType(title,content) {
  return request({
    url:'/admin/reportKind',
    method:'post',
    data: {
      title
      , content
    }

  })
}

//编辑举报类型
export function editReportType(id,title,content){
  return request({
    url:'/admin/reportKind',
    method:'put',
    data:{
      id,title,content
    }
  })
}

//删除举报类型
export function delReportType(id) {
  return request({
    url:'/admin/reportKind/'+id,
    method:'delete',
  })
}

//获取举报列表
export function getReportList(kindId,index){
  return request({
    url:'/admin/reportList',
    params:{
      kindId,index
    }
  })
}

//获取统计数据
export function getStatistics1(){
  return request({
    url:'/admin/count',
  })
}
export function getStatistics2(date,type){
  return request({
    url:'/admin/record',
    params:{
      date,type
    }
  })
}


//打开单个视频
export function openVideo(id){
  return request({
    url:'/data/data/'+id
  })
}


//获取习题列表
export function getPractice(index){
  return request({
    url:'/admin/practice',
    params:{
      index
    }
  })
}

//预览习题文档
export function toDoc(id){
  return request({
    url:'/admin/practice/'+id
  })
}

//删除习题文档
export function delDoc(id){
  return request({
    url:'/admin/practice/'+id,
    method:'delete'
  })
}

//下载习题
export function downDoc(id){{
  return request({
    url:'/admin/downloadPractice/'+id,
    method:'get',
    responseType:'blob'
  })
}}

//获取企业视频审核列表
export function getVideoApp(){
  return request({
    url:'/admin/companyDataList'
  })
}

//视频审核不通过
export function videoFail(cDid){
  return request({
    url:'/admin/auditCompanyDataFail/'+cDid,
    method:'put'
  })
}

//视频审核通过
export function videoSuccess(cDid){
  return request({
    url:'/admin/auditCompanyDataSuccess/'+cDid,
    method:'put'
  })
}

//获取企业视频列表      //传参搜索
export function getCompanyVideo(str){
  return request({
    url:'/admin/companyData',
    params:{
      str
    }
  })
}


//获取企业练习题     //传参搜索
export function getCompanyPractice(str){
  return request({
    url:'/admin/companyPractice',
    params:{
      str
    }
  })
}

//获得视频链接用来打开视频
export function getOpenPlayer(id){
  return request({
    url:'/admin/data/'+id,
  })
}


//前往处理举报
export function getDeal(id){
  return request({
    url:'/admin/reportDeal/'+id
  })
}

//举报成功
export function passReport(id){
  return request({
    url:'/admin/reportSuccess/'+id,
    method:'put'
  })
}

//举报失败
export function failReport(id){
  return request({
    url:'/admin/reportFail/'+id,
    method:'put',
  })
}


//招聘信息删改查
export function getRecList(keywords){
  return request({
    url:'/admin/recruitment',
    params:{
      name:keywords
    }
  })
}

//删除招聘信息
export function delRec(id){
  return request({
    url:'/admin/recruitment/'+id,
    method:'delete'
  })
}

//下架或发布
export function releaseSwitch(id){
  return request({
    url:'/admin/release',
    method:'put',
    data:{id}
  })
}

//个人信息展示
export function getArchives(type,id){        //传isMyself表示自己看
  return request({
    url:'/admin/unit/'+id,
    params:{
      type
    }
  })
}


